import { sequelize } from './sequelize.js';
import User from '../model/User.js'



// 同步模型到数据库
export const sync = async function () {
    try {
        await sequelize.authenticate();
        console.log('Connection has been established successfully.');
    } catch (error) {
        console.error('Unable to connect to the database:', error);
    }
    sequelize.sync().then(() => {
        console.log('数据库和表已成功创建');

        创建用户
        User.create({    
            firstname: 'yuwu',
            lastname: 'chuji',
            age: '20',
            email: 'abc@example.com',

        })
    }).catch(err => {
        console.error('创建数据库和表时出错:', err);
    });
}